<?php 
/**
 *消息类型
 DROP TABLE IF EXISTS `dict_message_type`;
CREATE TABLE `dict_message_type` (
  `mt_id` int(11) NOT NULL,
  `name` varchar(20) NOT NULL,
  `definition` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`mt_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 */
Class MessageTypeModel extends Model{
  /**
   * 获得所有的消息类型
   * @return [type] [description]
   */
  public function selectAllMessageType()
  {
    return $this->select();
  }

  /**
   * 判断消息名是否已经存在
   * @return boolean [description]
   */
  private function isExist($name)
  {
    if ($this->where('name=' . $name)->find()) {
      return true;
    } else {
      return false;
    }
  }

  /**
   * 插入一种消息类型
   */
  public function addMessageType($name, $definition="")
  {
    // 判断消息类型名是否存在
    if (!$this->isExist($name)) {
      $data['name'] = $name;
      $data['definition'] = $definition;
      return $this->add($data);
    } else {
      return false;
    }
  }
  /**
   * 删除消息类型
   * @param  [type] $mt_id [description]
   * @return [type]        [description]
   */
  public function delMessageByMtid($mt_id)
  {
    return $this->where('mt_id=' . $mt_id)->delete();
  }
  
}
 ?>